#ifndef TMTHREADMANAGER_H
#define TMTHREADMANAGER_H
//
#include <QObject>

#include "ClientThread.h"

//
// Thread manager manages threads in a pool - passing the newly connected socket descriptors to
// threads, optionally creating them when needed.
class CTMThreadManager : public QObject
{
Q_OBJECT
public:
	CTMThreadManager(QObject *pParent = NULL);
	
public slots:
	// called when a new connection has arrived:
	void newConnection(int nSocketDescriptor);
	
private slots:	
	// called to create new threads:
	void createThreads(int nCount);
	
	// called when one of the threads changes state - we watch this to seewhen a thread goes back to the idle state,
	void threadStateChanged(CClientThread::ClientThreadState nSate);
	
private:
	// list of all threads we're managing:
	QList<CClientThread*> m_liThreads;
	
	// list of all threads that are in the idle state:
	QList<CClientThread*> m_liIdleThreads;
};
#endif
